package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Test2 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        try(
                Connection connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                        "root","root");

        ){
            Statement state=connection.createStatement();
            String sql="DELETE FROM student1" +
                    " WHERE name NOT LIKE 'test_'" +
                    "AND name NOT LIKE 'test1_'";

            int count=state.executeUpdate(sql);
            if(count>0){
                System.out.println("影响了表中"+count+"条数据");
            }
            System.out.println("sql执行完毕");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
